package fi.internetix.ck;

import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class TextareaNodePrinter extends HTMLNodePrinter {

  public void processNode(Node node, StringBuilder output) {
    Element element = (Element) node;
    String tagName = NodePrinterUtils.extractLowercaseTagName(element.getTagName());
    output.append('<');
    output.append(tagName);

    NamedNodeMap attrs = element.getAttributes();
    for (int i = 0; i < attrs.getLength(); i++) {
      processAttribute(element, attrs.item(i), output);
    }

    output.append('>');
    NodeList children = element.getChildNodes();
    for (int i = 0; i < children.getLength(); i++) {
      NodePrinterUtils.getNodePrinter(children.item(i)).processNode(children.item(i), output);
    }
    output.append("</");
    output.append(tagName);
    output.append('>');
  }

}
